# Copyright 2021, Google LLC
#
# SPDX-License-Identifier: BSD-2-Clause
load(":build_defs.bzl", "gen_test_digit")
load("//java/de/jflex/migration/unicodedatatest:build_defs.bzl", "KNOWN_VERSIONS")

package(default_visibility = [
    "//javatests/de/jflex/migration/unicodedatatest/testdigit:__pkg__",
    "//javatests/de/jflex/testcase/unicode:__subpackages__",
])

java_binary(
    name = "generator",
    testonly = True,
    srcs = ["DigitTestGenerator.java"],
    main_class = "de.jflex.migration.unicodedatatest.testdigit.DigitTestGenerator",
    deps = [
        ":testdigit",
        "//java/de/jflex/migration/unicodedatatest/base",
        "//java/de/jflex/ucd",
        "//java/de/jflex/ucd_generator/scanner",
        "//java/de/jflex/ucd_generator/ucd",
        "//third_party/com/google/guava",
        "//third_party/org/apache/velocity",
    ],
)

java_library(
    name = "testdigit",
    testonly = True,
    srcs = glob(["Unicode*.java"]),
    resources = [
        "UnicodeDigit.flex.vm",
        "UnicodeDigitGolden.vm",
        "UnicodeDigitTest.java.vm",
    ],
    deps = [
        ":digit_blocks",
        "//java/de/jflex/migration/unicodedatatest/base",
        "//java/de/jflex/testing/unicodedata",
        "//java/de/jflex/ucd",
        "//java/de/jflex/ucd_generator/ucd",
        "//third_party/com/google/guava",
    ],
)

java_library(
    name = "digit_blocks",
    testonly = True,
    srcs = ["DigitBlocks.java"],
    deps = [
        "//java/de/jflex/testing/unicodedata",
        "//java/de/jflex/ucd",
        "//third_party/com/google/auto_value",
        "//third_party/com/google/guava",
    ],
)

filegroup(
    name = "generate",
    testonly = True,
    srcs = [
        "gen_test_digit_%s_%s" % (x, y)
        for (x, y) in KNOWN_VERSIONS
    ],
)

[gen_test_digit(
    name = "gen_test_digit_%s_%s" % (x, y),
    ucd = "//third_party/unicode:ucd_%s_%s" % (x, y),
    version = "%s.%s" % (x, y),
) for (x, y) in KNOWN_VERSIONS]
